<?php
/**
 * 产品评论 列表文件
 *
 * @author		Arthur(ArthurXF@gmail.com)
 * @copyright	(c) 2006 by bizeway.com
 * @version		$Id$
 * @package		ArthurXF
 * @subpackage	comments
 */
require_once('config/config.inc.php');
require_once("class/comments.class.php");

$objWebInit = new comments();
//数据库连接参数
$objWebInit->setDBG($arrGPdoDB);
$objWebInit->db();
//smarty参数
$objWebInit->arrGSmarty = $arrGSmarty;

//全站公用block
@include '../_block.php';


//安装检查
if($arrGMeta['comments']['name'] === null){
	echo 'BIWEB网站系统产品评论功能栏目尚未安装，如需安装成配置文件分类，请配置好config/type.inc.php后，<a href=install.php>点击安装</a>，如要使用数据库分类，直接<a href=install.php>点击安装</a>';
	exit;
}

if ($_SERVER["REQUEST_METHOD"] == "POST"){

	if(empty($_SESSION['user_name']))	check::AlertExit('你还没登陆!!',-1);
	if(empty($_POST['title']))	check::AlertExit('对不起，留言标题必须填写!!',-1);
	if(empty($_POST['intro']))	check::AlertExit('对不起，留言内容必须填写!!',-1);

	$strIP = check::getip();
	$_POST['user_ip'] = $strIP;
	$_POST['commentsname'] = $_SESSION['user_name'];

	$objWebInit->saveInfo($_POST,0);

	if($arrGWeb['file_static']){
		//生成静态页面
		$arrGCache['cache_root'] = __WEB_ROOT .$arrGWeb['cache_url'];
		include_once(__WEB_ROOT."/product/config/var.inc.php");
		$intID = intval($_POST['product_id']);
		$strDir = ceil($intID/$arrGCache['cache_filenum']);
		$objCache = new cache($arrGCache['cache_root'].'-'.$strDir.'/'.$intID.'.html',$arrGCache['cache_time']);
		$objCache->cache_start();
		$strContents = @file_get_contents('http://'.$_SERVER["HTTP_HOST"].'/product/detail.php?id='.$intID);
		if($strContents){
			echo $strContents;
		}
		$objCache->cache_end(false);
	}


	check::WindowLocation($_SERVER['HTTP_REFERER']);
}
?>